const express = require('express')
const router = express.Router()

// 导入处理函数
const userInfoHandle = require('../router_handle/userInfo')
// 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
// 导入验证规则
const { up_userInfo_schema } = require('../schema/userInfo')
const { up_psw_schema, up_avatar_schema } = require('../schema/user')

// 获取用户的接口
router.get('/userInfo', userInfoHandle.getUser)

// 更改用户信息的接口
router.post('/userInfo', expressJoi(up_userInfo_schema), userInfoHandle.updateUser)

// 重置密码的接口
router.post('/updatePsw', expressJoi(up_psw_schema), userInfoHandle.updatePsw)

// 更换用户头像的接口
router.post('/updateAvatar', expressJoi(up_avatar_schema), userInfoHandle.updateAvatar)

module.exports = router


